package com.qfjy.service.impl;

import com.qfjy.entity.po.User;
import com.qfjy.entity.vo.UserVO;
import com.qfjy.mapper.UserMapper;
import com.qfjy.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author guoweixin
 * @Date 2022/11/28
 * @Version 1.0
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper userMapper;
    /**
     * 列表查询 全部数据
     *
     * @return
     */
    @Override
    public List<User> selectList() {
        return userMapper.selectList();
    }

    /**
     * TODO 用户列表 条件查找
     *
     * @param userVO
     */
    @Override
    public List<User> listCondition(UserVO userVO) {
        return userMapper.listCondition(userVO);
    }

    /**
     * TODO 批量添加
     *
     * @param list
     */
    @Override
    public int insertBatch(List<User> list) {
        return userMapper.insertBatch(list);
    }

    /**
     * TODO 根据ID进行删除
     *
     * @param id
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    /**
     * TODO 批量删除
     *
     * @param ids ids数组
     */
    @Override
    public int deleteBatch(String[] ids) {
        return userMapper.deleteBatch(ids);
    }

    /**
     * TODO
     * 根据id查询用户信息
     *
     * @param id
     */
    @Override
    public User selectByPrimaryKey(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    /**
     * TODO 根据ID修改状态
     *
     * @param status
     * @param id
     * @return
     */
    @Override
    public int updateUserStatusById(int status, int id) {
        return userMapper.updateUserStatusById(status,id);
    }

    /**
     * TODO 查询所有的邮箱
     */
    @Override
    public List<String> selectListEmail() {
        return userMapper.selectListEmail();
    }

    /**
     * TODO 根据wid查询user
     *
     * @param wid
     */
    @Override
    public User selectUserByWid(int wid) {
        return userMapper.selectUserByWid(wid);
    }

    /**
     * TODO 根据email查询user
     *
     * @param email
     */
    @Override
    public User selectUserByEmail(String email) {
        return userMapper.selectUserByEmail(email);
    }

    /**
     * TODO 微信登录（绑定）功能。 更新user wid值 根据email邮箱
     *
     * @param wid
     * @param email
     */
    @Override
    public int updateUserWidByEmail(int wid, String email) {
        return userMapper.updateUserWidByEmail(wid,email);
    }

    /**
     * TODO 更新用户信息
     *
     * @param user
     * @return
     */
    @Override
    public int updateByPrimaryKeySelective(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }
}
